package com.nijie.library.controller.sys;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.nijie.library.POJO.Message;
import com.nijie.library.POJO.modelPOJO.Role;
import com.nijie.library.service.sys.SysRoleSvc;

@Controller
@RequestMapping("role")
public class SysRoleCtrl {
	@Autowired
	private SysRoleSvc sysRoleSvc;
	@RequestMapping("role")
	public String page(){
		return "views/sys/role";
	}
	/**
	 * 列表
	 * @param title
	 * @return
	 */
	@RequestMapping("getRole")
	@ResponseBody
	public List<Role> getTitle(Role role,HttpSession session) {
		return sysRoleSvc.get(role);
	}
	
	/**
	 * 新增
	 * @param title
	 * @param session
	 * @return
	 */
	@RequestMapping("save")
	@ResponseBody
	public  Message<Role> save(Role role,HttpSession session) {
		Message<Role> message = new Message<Role>();
		message = sysRoleSvc.save(role);
		return message;
	}
	/**
	 * 更新
	 * @param title
	 * @param session
	 * @return
	 */
	@RequestMapping("modify")
	@ResponseBody
	public  Message<Role> modify(Role role,HttpSession session) {
		Message<Role> message = new Message<Role>();
		message =sysRoleSvc.modify(role);
		return message;
	}
	/**
	 * 删除
	 * @param ids
	 * @param status
	 * @return
	 */
	@RequestMapping("removeRole")
	@ResponseBody
	public  Message<Role> removeRole(String ids, String status,HttpSession session) {
		Message<Role> message = new Message<Role>();
		message = sysRoleSvc.modifyStatus(ids, status);
		return message;
	}
}
